<!DOCTYPE html>
<html>
<head>
    

    

    



    <meta charset="utf-8">
    
    
    
    <title>MySQL 安装（Windows）及常用命令 | Xiaoming&#39;s Blog | 一入前端深似海，从此妹子是路人。</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    
    <meta name="theme-color" content="#3F51B5">
    
    
    <meta name="keywords" content="MySQL,MySQL 增删改查">
    <meta name="description" content="MySQL 简介 MySQL 由瑞典MySQL AB公司开发，目前被oracle公司收购。  开源、关系型数据库管理系统  MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言。  版本分为【社区版】和【企业版（商业版）】  LAMP 环境：Linux + Apache + MySQL + PHP，一组常用来搭建动态网站或者服务器的开源软件  官网及下载地址：https://www.my">
<meta name="keywords" content="MySQL,MySQL 增删改查">
<meta property="og:type" content="article">
<meta property="og:title" content="MySQL 安装（Windows）及常用命令">
<meta property="og:url" content="http://www.lovebxm.com/2017/05/30/mysqlCommon/index.html">
<meta property="og:site_name" content="Xiaoming&#39;s Blog">
<meta property="og:description" content="MySQL 简介 MySQL 由瑞典MySQL AB公司开发，目前被oracle公司收购。  开源、关系型数据库管理系统  MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言。  版本分为【社区版】和【企业版（商业版）】  LAMP 环境：Linux + Apache + MySQL + PHP，一组常用来搭建动态网站或者服务器的开源软件  官网及下载地址：https://www.my">
<meta property="og:image" content="http://i1.piimg.com/567571/cd77651e085b7a11.png">
<meta property="og:image" content="http://i4.buimg.com/567571/dfd04630da46c7d6.png">
<meta property="og:updated_time" content="2017-05-30T15:43:34.738Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="MySQL 安装（Windows）及常用命令">
<meta name="twitter:description" content="MySQL 简介 MySQL 由瑞典MySQL AB公司开发，目前被oracle公司收购。  开源、关系型数据库管理系统  MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言。  版本分为【社区版】和【企业版（商业版）】  LAMP 环境：Linux + Apache + MySQL + PHP，一组常用来搭建动态网站或者服务器的开源软件  官网及下载地址：https://www.my">
<meta name="twitter:image" content="http://i1.piimg.com/567571/cd77651e085b7a11.png">
    
        <link rel="alternate" type="application/atom+xml" title="Xiaoming&#39;s Blog" href="/atom.xml">
    
    <link rel="shortcut icon" href="/favicon.ico">
    <link rel="stylesheet" href="//unpkg.com/hexo-theme-material-indigo@latest/css/style.css">
    <script>window.lazyScripts=[]</script>
</head>

<body>
    <div id="loading" class="active"></div>

    <aside id="menu"  >
  <div class="inner flex-row-vertical">
    <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menu-off">
        <i class="icon icon-lg icon-close"></i>
    </a>
    <div class="brand-wrap" style="background-image:url(/img/brand.jpg)">
      <div class="brand">
        <a href="/" class="avatar waves-effect waves-circle waves-light">
          <img src="/img/avatar.jpg">
        </a>
        <hgroup class="introduce">
          <h5 class="nickname">白小明</h5>
          <a href="mailto:80583600@qq.com" title="80583600@qq.com" class="mail">80583600@qq.com</a>
        </hgroup>
      </div>
    </div>
    <div class="scroll-wrap flex-col">
      <ul class="nav">
        
            <li class="waves-block waves-effect">
              <a href="/"  >
                <i class="icon icon-lg icon-home"></i>
                主页
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/tags"  >
                <i class="icon icon-lg icon-tags"></i>
                标签
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/hand-peace-o"  >
                <i class="icon icon-lg icon-hand-peace-o"></i>
                作品
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://github.com/bxm0927" target="_blank" >
                <i class="icon icon-lg icon-github"></i>
                Github
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/user"  >
                <i class="icon icon-lg icon-user"></i>
                关于我
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/404.html"  >
                <i class="icon icon-lg icon-link"></i>
                404 测试
              </a>
            </li>
        
      </ul>
    </div>
  </div>
</aside>

    <main id="main">
        <header class="top-header" id="header">
    <div class="flex-row">
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light on" id="menu-toggle">
          <i class="icon icon-lg icon-navicon"></i>
        </a>
        <div class="flex-col header-title ellipsis">MySQL 安装（Windows）及常用命令</div>
        
        <div class="search-wrap" id="search-wrap">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="back">
                <i class="icon icon-lg icon-chevron-left"></i>
            </a>
            <input type="text" id="key" class="search-input" autocomplete="off" placeholder="输入感兴趣的关键字">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="search">
                <i class="icon icon-lg icon-search"></i>
            </a>
        </div>
        
        
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menuShare">
            <i class="icon icon-lg icon-share-alt"></i>
        </a>
        
    </div>
</header>
<header class="content-header post-header">

    <div class="container fade-scale">
        <h1 class="title">MySQL 安装（Windows）及常用命令</h1>
        <h5 class="subtitle">
            
                <time datetime="2017-05-30T15:37:08.339Z" itemprop="datePublished" class="page-time">
  2017-05-30
</time>


            
        </h5>
    </div>

    


</header>


<div class="container body-wrap">
    
    <aside class="post-widget">
        <nav class="post-toc-wrap" id="post-toc">
            <h4>TOC</h4>
            <ol class="post-toc"><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#MySQL-简介"><span class="post-toc-number">1.</span> <span class="post-toc-text">MySQL 简介</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-4"><a class="post-toc-link" href="#MySQL-语法规则"><span class="post-toc-number">1.0.1.</span> <span class="post-toc-text">MySQL 语法规则</span></a></li><li class="post-toc-item post-toc-level-4"><a class="post-toc-link" href="#MySQL-安装"><span class="post-toc-number">1.0.2.</span> <span class="post-toc-text">MySQL 安装</span></a></li><li class="post-toc-item post-toc-level-4"><a class="post-toc-link" href="#MySQL-配置"><span class="post-toc-number">1.0.3.</span> <span class="post-toc-text">MySQL 配置</span></a></li></ol></li></ol></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#启动-关闭-MySQL-服务"><span class="post-toc-number">2.</span> <span class="post-toc-text">启动 / 关闭 MySQL 服务</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#进入-MySQL"><span class="post-toc-number">3.</span> <span class="post-toc-text">进入 MySQL</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#退出-MySQL"><span class="post-toc-number">4.</span> <span class="post-toc-text">退出 MySQL</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#修改MySQL提示符"><span class="post-toc-number">5.</span> <span class="post-toc-text">修改MySQL提示符</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#查看-MySQL-版本信息"><span class="post-toc-number">6.</span> <span class="post-toc-text">查看 MySQL 版本信息</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#显示服务器当前版本"><span class="post-toc-number">7.</span> <span class="post-toc-text">显示服务器当前版本</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#显示服务器当前时间"><span class="post-toc-number">8.</span> <span class="post-toc-text">显示服务器当前时间</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#显示当前用户"><span class="post-toc-number">9.</span> <span class="post-toc-text">显示当前用户</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#创建数据库"><span class="post-toc-number">10.</span> <span class="post-toc-text">创建数据库</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#查看警告信息"><span class="post-toc-number">11.</span> <span class="post-toc-text">查看警告信息</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#显示数据库列表"><span class="post-toc-number">12.</span> <span class="post-toc-text">显示数据库列表</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#显示表"><span class="post-toc-number">13.</span> <span class="post-toc-text">显示表</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#查看表结构"><span class="post-toc-number">14.</span> <span class="post-toc-text">查看表结构</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#查看表内容"><span class="post-toc-number">15.</span> <span class="post-toc-text">查看表内容</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#修改数据库"><span class="post-toc-number">16.</span> <span class="post-toc-text">修改数据库</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#删除数据库"><span class="post-toc-number">17.</span> <span class="post-toc-text">删除数据库</span></a></li></ol>
        </nav>
    </aside>
    
<article id="post-mysqlCommon"
  class="post-article article-type-post fade" itemprop="blogPost">

    <div class="post-card">
        <h1 class="post-card-title">MySQL 安装（Windows）及常用命令</h1>
        <div class="post-meta">
            <time class="post-time" title="2017-05-30 23:37:08" datetime="2017-05-30T15:37:08.339Z"  itemprop="datePublished">2017-05-30</time>

            


            
<span id="busuanzi_container_page_pv" title="文章总阅读量" style='display:none'>
    <i class="icon icon-eye icon-pr"></i><span id="busuanzi_value_page_pv"></span>
</span>


            

        </div>
        <div class="post-content" id="post-content" itemprop="postContent">
            <h2 id="MySQL-简介"><a href="#MySQL-简介" class="headerlink" title="MySQL 简介"></a>MySQL 简介</h2><ol>
<li><p>MySQL 由瑞典MySQL AB公司开发，目前被oracle公司收购。</p>
</li>
<li><p>开源、关系型数据库管理系统</p>
</li>
<li><p>MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言。</p>
</li>
<li><p>版本分为【社区版】和【企业版（商业版）】</p>
</li>
<li><p>LAMP 环境：Linux + Apache + MySQL + PHP，一组常用来搭建动态网站或者服务器的开源软件</p>
</li>
<li><p>官网及下载地址：<a href="https://www.mysql.com/" target="_blank" rel="external">https://www.mysql.com/</a></p>
</li>
</ol>
<a id="more"></a>
<h4 id="MySQL-语法规则"><a href="#MySQL-语法规则" class="headerlink" title="MySQL 语法规则"></a>MySQL 语法规则</h4><ol>
<li><p>关键字与函数名称全部大写</p>
</li>
<li><p>数据库名称、表名称、字段名称全部小写</p>
</li>
<li><p>SQL 语句必须以分号结尾</p>
</li>
</ol>
<h4 id="MySQL-安装"><a href="#MySQL-安装" class="headerlink" title="MySQL 安装"></a>MySQL 安装</h4><p>安装方式分为：MSI安装（Windows installer）、ZIP安装</p>
<p>下载之前需要登录</p>
<p><a href="http://jingyan.baidu.com/article/363872ecd8235d6e4ba16fc7.html" target="_blank" rel="external">百度经验</a></p>
<h4 id="MySQL-配置"><a href="#MySQL-配置" class="headerlink" title="MySQL 配置"></a>MySQL 配置</h4><p>在 cmd 中输入 mysql，提示【’mysql’ 不是内部或外部命令，也不是可运行的程序<br>或批处理文件】</p>
<p>只需将MySQL安装路径添加系统环境变量即可。</p>
<p>环境变量中编辑系统变量Path，添加如下路径，最后，在 cmd 中输入 mysql 检测。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">;C:\Program Files\MySQL\MySQL Server 5.7\bin</div></pre></td></tr></table></figure>
<p><a href="http://jingyan.baidu.com/article/3ea51489e6cfbe52e61bba25.html" target="_blank" rel="external">mysql ERROR 1045 (28000): 错误解决办法</a></p>
<hr>
<h2 id="启动-关闭-MySQL-服务"><a href="#启动-关闭-MySQL-服务" class="headerlink" title="启动 / 关闭 MySQL 服务"></a>启动 / 关闭 MySQL 服务</h2><p>以管理员身份运行cmd、也可以在任务管理器中开启/关闭服务<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">C:\Windows\system32&gt;net start mysql57</div><div class="line">MySQL57 服务正在启动 .</div><div class="line">MySQL57 服务已经启动成功。</div><div class="line"></div><div class="line"></div><div class="line">C:\Windows\system32&gt;net stop mysql57</div><div class="line">MySQL57 服务正在停止.</div><div class="line">MySQL57 服务已成功停止。</div></pre></td></tr></table></figure></p>
<h2 id="进入-MySQL"><a href="#进入-MySQL" class="headerlink" title="进入 MySQL"></a>进入 MySQL</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div></pre></td><td class="code"><pre><div class="line">C:\Users\bxm09&gt;mysql -u root -p</div><div class="line">Enter password:</div><div class="line">Welcome to the MySQL monitor.  Commands end with ; or \g.</div><div class="line">Your MySQL connection id is 14</div><div class="line">Server version: 5.7.18-log MySQL Community Server (GPL)</div><div class="line"></div><div class="line">Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.</div><div class="line"></div><div class="line">Oracle is a registered trademark of Oracle Corporation and/or its</div><div class="line">affiliates. Other names may be trademarks of their respective</div><div class="line">owners.</div><div class="line"></div><div class="line">Type &apos;help;&apos; or &apos;\h&apos; for help. Type &apos;\c&apos; to clear the current input statement.</div></pre></td></tr></table></figure>
<figure class="image-bubble">
                <div class="img-lightbox">
                    <div class="overlay"></div>
                    <img src="http://i1.piimg.com/567571/cd77651e085b7a11.png" alt="" title="">
                </div>
                <div class="image-caption"></div>
            </figure>
<h2 id="退出-MySQL"><a href="#退出-MySQL" class="headerlink" title="退出 MySQL"></a>退出 MySQL</h2><p>下面的三个命令都可以<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">mysql&gt; exit;</div><div class="line">mysql&gt; quit;</div><div class="line">mysql&gt; \q;</div><div class="line"></div><div class="line">Bye</div></pre></td></tr></table></figure></p>
<h2 id="修改MySQL提示符"><a href="#修改MySQL提示符" class="headerlink" title="修改MySQL提示符"></a>修改MySQL提示符</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">mysql&gt; prompt bxm&gt;</div><div class="line">PROMPT set to &apos;bxm&gt;&apos;</div><div class="line">bxm&gt;</div><div class="line"></div><div class="line">mysql&gt; prompt \D</div><div class="line">PROMPT set to &apos;\D&apos;</div><div class="line">Wed Apr 26 14:18:39 2017</div></pre></td></tr></table></figure>
<figure class="image-bubble">
                <div class="img-lightbox">
                    <div class="overlay"></div>
                    <img src="http://i4.buimg.com/567571/dfd04630da46c7d6.png" alt="" title="">
                </div>
                <div class="image-caption"></div>
            </figure>
<h2 id="查看-MySQL-版本信息"><a href="#查看-MySQL-版本信息" class="headerlink" title="查看 MySQL 版本信息"></a>查看 MySQL 版本信息</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div></pre></td><td class="code"><pre><div class="line">mysql&gt; status</div><div class="line">--------------</div><div class="line">mysql  Ver 14.14 Distrib 5.7.18, for Win64 (x86_64)</div><div class="line"></div><div class="line">Connection id:          11</div><div class="line">Current database:</div><div class="line">Current user:           ODBC@</div><div class="line">SSL:                    Not in use</div><div class="line">Using delimiter:        ;</div><div class="line">Server version:         5.7.18-log MySQL Community Server (GPL)</div><div class="line">Protocol version:       10</div><div class="line">Connection:             localhost via TCP/IP</div><div class="line">Server characterset:    utf8</div><div class="line">Db     characterset:    utf8</div><div class="line">Client characterset:    gbk</div><div class="line">Conn.  characterset:    gbk</div><div class="line">TCP port:               3306</div><div class="line">Uptime:                 41 min 32 sec</div><div class="line"></div><div class="line">Threads: 1  Questions: 24  Slow queries: 0  Opens: 100  Flush tables: 1  Open tables: 95  Queries per second avg: 0.009</div><div class="line">--------------</div></pre></td></tr></table></figure>
<h2 id="显示服务器当前版本"><a href="#显示服务器当前版本" class="headerlink" title="显示服务器当前版本"></a>显示服务器当前版本</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">mysql&gt; SELECT VERSION();</div><div class="line">+------------+</div><div class="line">| VERSION()  |</div><div class="line">+------------+</div><div class="line">| 5.7.18-log |</div><div class="line">+------------+</div><div class="line">1 row in set (0.00 sec)</div></pre></td></tr></table></figure>
<h2 id="显示服务器当前时间"><a href="#显示服务器当前时间" class="headerlink" title="显示服务器当前时间"></a>显示服务器当前时间</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">mysql&gt; SELECT NOW();</div><div class="line">+---------------------+</div><div class="line">| NOW()               |</div><div class="line">+---------------------+</div><div class="line">| 2017-04-26 14:26:07 |</div><div class="line">+---------------------+</div><div class="line">1 row in set (0.00 sec)</div></pre></td></tr></table></figure>
<h2 id="显示当前用户"><a href="#显示当前用户" class="headerlink" title="显示当前用户"></a>显示当前用户</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">mysql&gt; SELECT USER();</div><div class="line">+--------+</div><div class="line">| USER() |</div><div class="line">+--------+</div><div class="line">| ODBC@  |</div><div class="line">+--------+</div><div class="line">1 row in set (0.00 sec)</div></pre></td></tr></table></figure>
<h2 id="创建数据库"><a href="#创建数据库" class="headerlink" title="创建数据库"></a>创建数据库</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">CREATE &#123;DATABASE | SCHEMA&#125; [IF NOT EXISTS] db_name [DEFAULT] CHARACTER SET [=] charset_name;</div></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">mysql&gt; CREATE DATABASE demo1;</div><div class="line">Query OK, 1 row affected (0.00 sec)</div><div class="line"></div><div class="line">mysql&gt; CREATE DATABASE IF NOT EXISTS demo1;</div><div class="line">Query OK, 1 row affected, 1 warning (0.00 sec)</div></pre></td></tr></table></figure>
<h2 id="查看警告信息"><a href="#查看警告信息" class="headerlink" title="查看警告信息"></a>查看警告信息</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">mysql&gt; SHOW WARNINGS;</div><div class="line">+-------+------+------------------------------------------------+</div><div class="line">| Level | Code | Message                                        |</div><div class="line">+-------+------+------------------------------------------------+</div><div class="line">| Note  | 1007 | Can&apos;t create database &apos;demo1&apos;; database exists |</div><div class="line">+-------+------+------------------------------------------------+</div><div class="line">1 row in set (0.00 sec)</div></pre></td></tr></table></figure>
<h2 id="显示数据库列表"><a href="#显示数据库列表" class="headerlink" title="显示数据库列表"></a>显示数据库列表</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div></pre></td><td class="code"><pre><div class="line">mysql&gt; SHOW DATABASES;</div><div class="line">+--------------------+</div><div class="line">| Database           |</div><div class="line">+--------------------+</div><div class="line">| information_schema |</div><div class="line">| demo1              |</div><div class="line">| mysql              |</div><div class="line">| performance_schema |</div><div class="line">| sakila             |</div><div class="line">| sys                |</div><div class="line">| world              |</div><div class="line">+--------------------+</div><div class="line">7 rows in set (0.00 sec)</div></pre></td></tr></table></figure>
<h2 id="显示表"><a href="#显示表" class="headerlink" title="显示表"></a>显示表</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line">mysql&gt; SHOW TABLES;</div><div class="line">+---------------------+</div><div class="line">| Tables_in_shopimooc |</div><div class="line">+---------------------+</div><div class="line">| imooc_admin         |</div><div class="line">| imooc_album         |</div><div class="line">| imooc_cate          |</div><div class="line">| imooc_pro           |</div><div class="line">| imooc_user          |</div><div class="line">+---------------------+</div><div class="line">5 rows in set (0.00 sec)</div></pre></td></tr></table></figure>
<h2 id="查看表结构"><a href="#查看表结构" class="headerlink" title="查看表结构"></a>查看表结构</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div></pre></td><td class="code"><pre><div class="line">mysql&gt; use shopImooc</div><div class="line">Database changed</div><div class="line">mysql&gt; desc imooc_admin;</div><div class="line">+----------+------------------+------+-----+---------+----------------+</div><div class="line">| Field    | Type             | Null | Key | Default | Extra          |</div><div class="line">+----------+------------------+------+-----+---------+----------------+</div><div class="line">| id       | int(10) unsigned | NO   | PRI | NULL    | auto_increment |</div><div class="line">| username | varchar(30)      | NO   | UNI | NULL    |                |</div><div class="line">| password | char(32)         | NO   |     | NULL    |                |</div><div class="line">| email    | varchar(60)      | NO   |     | NULL    |                |</div><div class="line">+----------+------------------+------+-----+---------+----------------+</div><div class="line">4 rows in set (0.00 sec)</div></pre></td></tr></table></figure>
<h2 id="查看表内容"><a href="#查看表内容" class="headerlink" title="查看表内容"></a>查看表内容</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line">mysql&gt; select * from imooc_admin;</div><div class="line">+----+----------+----------------------------------+-----------------+</div><div class="line">| id | username | password                         | email           |</div><div class="line">+----+----------+----------------------------------+-----------------+</div><div class="line">|  1 | king     | b2086154f101464aab3328ba7e060deb | 80583600@qq,com |</div><div class="line">|  2 | admin    | admin                            | admin@qq.com    |</div><div class="line">|  3 | bxm      | bxm                              | bxm@qq.com      |</div><div class="line">+----+----------+----------------------------------+-----------------+</div><div class="line">3 rows in set (0.00 sec)</div></pre></td></tr></table></figure>
<h2 id="修改数据库"><a href="#修改数据库" class="headerlink" title="修改数据库"></a>修改数据库</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">ALTER &#123;DATABASE | SCHEMA&#125; db_name [DEFAULT] CHARACTER SET [=] charset_name;</div></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line">mysql&gt; ALTER DATABASE demo1 CHARACTER SET gbk;</div><div class="line">Query OK, 1 row affected (0.01 sec)</div><div class="line"></div><div class="line">mysql&gt; SHOW CREATE DATABASE demo1;</div><div class="line">+----------+---------------------------------------------------------------+</div><div class="line">| Database | Create Database                                               |</div><div class="line">+----------+---------------------------------------------------------------+</div><div class="line">| demo1    | CREATE DATABASE `demo1` /*!40100 DEFAULT CHARACTER SET gbk */ |</div><div class="line">+----------+---------------------------------------------------------------+</div><div class="line">1 row in set (0.00 sec)</div></pre></td></tr></table></figure>
<h2 id="删除数据库"><a href="#删除数据库" class="headerlink" title="删除数据库"></a>删除数据库</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">DROP &#123;DATABASE | SCHEMA&#125; [IF EXISTS] db_name;</div></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">mysql&gt; DROP DATABASE demo1;</div><div class="line">Query OK, 0 rows affected (0.02 sec)</div></pre></td></tr></table></figure>

        </div>

        <blockquote class="post-copyright">
    <div class="content">
        
<span class="post-time">
    最后更新时间：<time datetime="2017-05-30T15:43:34.738Z" itemprop="dateUpdated">2017-05-30 23:43:34</time>
</span><br>


        
        原始文章链接：<a href="/2017/05/30/mysqlCommon/" target="_blank" rel="external">http://www.lovebxm.com/2017/05/30/mysqlCommon/</a>
        
    </div>
    <footer>
        <a href="http://www.lovebxm.com">
            <img src="/img/avatar.jpg" alt="白小明">
            白小明
        </a>
    </footer>
</blockquote>

        
<div class="page-reward">
    <a id="rewardBtn" href="javascript:;" class="page-reward-btn waves-effect waves-circle waves-light">赏</a>
</div>



        <div class="post-footer">
            
	<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/MySQL/">MySQL</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/MySQL-增删改查/">MySQL 增删改查</a></li></ul>


            
<div class="page-share-wrap">
    

<div class="page-share" id="pageShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://www.lovebxm.com/2017/05/30/mysqlCommon/&title=《MySQL 安装（Windows）及常用命令》 — Xiaoming's Blog&pic=http://www.lovebxm.com/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://www.lovebxm.com/2017/05/30/mysqlCommon/&title=《MySQL 安装（Windows）及常用命令》 — Xiaoming's Blog&source=MySQL 简介
MySQL 由瑞典MySQL AB公司开发，目前被oracle公司收购。

开源、关系型数据库管理系统

MySQL所使用的SQL语言是..." data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://www.lovebxm.com/2017/05/30/mysqlCommon/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《MySQL 安装（Windows）及常用命令》 — Xiaoming's Blog&url=http://www.lovebxm.com/2017/05/30/mysqlCommon/&via=http://www.lovebxm.com" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://www.lovebxm.com/2017/05/30/mysqlCommon/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>



    <a href="javascript:;" id="shareFab" class="page-share-fab waves-effect waves-circle">
        <i class="icon icon-share-alt icon-lg"></i>
    </a>
</div>



        </div>
    </div>

    
<nav class="post-nav flex-row flex-justify-between">
  
    <div class="waves-block waves-effect prev">
      <a href="/2017/05/30/PHP_Cookie_Session/" id="post-prev" class="post-nav-link">
        <div class="tips"><i class="icon icon-angle-left icon-lg icon-pr"></i> Prev</div>
        <h4 class="title">PHP cookie 与 session</h4>
      </a>
    </div>
  

  
    <div class="waves-block waves-effect next">
      <a href="/2017/05/30/WPO/" id="post-next" class="post-nav-link">
        <div class="tips">Next <i class="icon icon-angle-right icon-lg icon-pl"></i></div>
        <h4 class="title">网站性能优化（Yahoo军规）</h4>
      </a>
    </div>
  
</nav>



    










    <div id="cloud-tie-wrapper" class="comments cloud-tie-wrapper"></div>
    <script>
    var cloudTieConfig = {
        url: 'http://www.lovebxm.com/2017/05/30/mysqlCommon/index.html',
        sourceId: 'mysqlCommon',
        productKey: '294c776acae94037bdd6605780e549e4',
        target: 'cloud-tie-wrapper',
        pcFiles: [
            '//unpkg.com/hexo-theme-material-indigo@latest/css/cloudTie/pc.css',
            '//unpkg.com/hexo-theme-material-indigo@latest/js/cloudTie/pc.min.js',
        ],
        mobileFiles: [
            '//unpkg.com/hexo-theme-material-indigo@latest/css/cloudTie/mobile.css',
            '//unpkg.com/hexo-theme-material-indigo@latest/js/cloudTie/mobile.min.js'
        ]
    };
    </script>
    <script src="//unpkg.com/hexo-theme-material-indigo@latest/js/cloudTie/loader.min.js"></script>







</article>

<div id="reward" class="page-modal reward-lay">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <h3 class="reward-title">
        <i class="icon icon-quote-left"></i>
        谢谢您~
        <i class="icon icon-quote-right"></i>
    </h3>
    <ul class="reward-items">
        
        <li>
            <img src="/img/wechat.jpg" title="微信打赏二维码" alt="微信打赏二维码">
            <p>微信</p>
        </li>
        

        
        <li>
            <img src="/img/alipay.jpg" title="支付宝打赏二维码" alt="支付宝打赏二维码">
            <p>支付宝</p>
        </li>
        
    </ul>
</div>



</div>

        <!-- <footer class="footer">
    <div class="top">
        
<p>
    <span id="busuanzi_container_site_uv" style='display:none'>
        总访客数：<span id="busuanzi_value_site_uv"></span>
    </span>
    <span id="busuanzi_container_site_pv" style='display:none'>
        总访问量：<span id="busuanzi_value_site_pv"></span>
    </span>
</p>


        <p>
            
                <span><a href="/atom.xml" target="_blank" class="rss" title="rss"><i class="icon icon-lg icon-rss"></i></a></span>
            
            <span>博客内容遵循<a rel="license" href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh">知识共享 署名 - 非商业性 - 相同方式共享 4.0 国际协议</a></span>
        </p>
    </div>
    <div class="bottom">
        <p>
            <span>Power by <a href="http://hexo.io/" target="_blank">Hexo</a> Theme <a href="https://github.com/yscoder/hexo-theme-indigo" target="_blank">indigo</a></span>
            <span>白小明 &copy; 2017</span>
        </p>
    </div>
</footer> -->

<footer class="footer">
    <div class="top">
        
<p>
    <span id="busuanzi_container_site_uv" style='display:none'>
        总访客数：<span id="busuanzi_value_site_uv"></span>
    </span>
    <span id="busuanzi_container_site_pv" style='display:none'>
        总访问量：<span id="busuanzi_value_site_pv"></span>
    </span>
</p>


        <p>
            
                <span><a href="/atom.xml" target="_blank" class="rss" title="rss"><i class="icon icon-lg icon-rss"></i></a></span>
            
            <span>博客内容遵循<a rel="license" href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh">知识共享 署名 - 非商业性 - 相同方式共享 4.0 国际协议</a></span>
            <span>白小明 &copy; 2017</span>
        </p>
    </div>
    <div class="bottom">
        <p>
        <span>
        <a target="_blank" href="mailto:80583600@qq.com" style="border-bottom:none">
        <img src="" alt="E-mail 联系" style="width:20px;height:20px;border:none;">
        </a>
        </span>

        <span>
        <a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=80583600&site=qq&menu=yes" style="border-bottom:none">
        <img src="" title="QQ 联系" style="width:22px;height:22px;border:none;"></a>
        </span>

        <span>
        <a target="_blank" href="https://github.com/bxm0927" style="border-bottom:none">
        <img src="" alt="GitHub microzz" title="GitHub 联系" style="width:19px;height:19px;border:none;"></a>
        </span>
        </p>
    </div>
</footer>




    </main>
    <div class="mask" id="mask"></div>
<a href="javascript:;" id="gotop" class="waves-effect waves-circle waves-light"><span class="icon icon-lg icon-chevron-up"></span></a>



<div class="global-share" id="globalShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://www.lovebxm.com/2017/05/30/mysqlCommon/&title=《MySQL 安装（Windows）及常用命令》 — Xiaoming's Blog&pic=http://www.lovebxm.com/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://www.lovebxm.com/2017/05/30/mysqlCommon/&title=《MySQL 安装（Windows）及常用命令》 — Xiaoming's Blog&source=MySQL 简介
MySQL 由瑞典MySQL AB公司开发，目前被oracle公司收购。

开源、关系型数据库管理系统

MySQL所使用的SQL语言是..." data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://www.lovebxm.com/2017/05/30/mysqlCommon/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《MySQL 安装（Windows）及常用命令》 — Xiaoming's Blog&url=http://www.lovebxm.com/2017/05/30/mysqlCommon/&via=http://www.lovebxm.com" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://www.lovebxm.com/2017/05/30/mysqlCommon/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>


<div class="page-modal wx-share" id="wxShare">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <p>扫一扫，分享到微信</p>
    <img src="" alt="微信分享二维码">
</div>




    <script src="//cdn.bootcss.com/node-waves/0.7.4/waves.min.js"></script>
<script>
var BLOG = { ROOT: '/', SHARE: true, REWARD: true };



</script>

<script src="//unpkg.com/hexo-theme-material-indigo@latest/js/main.min.js"></script>


<div class="search-panel" id="search-panel">
    <ul class="search-result" id="search-result"></ul>
</div>
<template id="search-tpl">
<li class="item">
    <a href="{path}" class="waves-block waves-effect">
        <div class="title ellipsis" title="{title}">{title}</div>
        <div class="flex-row flex-middle">
            <div class="tags ellipsis">
                {tags}
            </div>
            <time class="flex-col time">{date}</time>
        </div>
    </a>
</li>
</template>

<script src="//unpkg.com/hexo-theme-material-indigo@latest/js/search.min.js" async></script>






<script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>



<script>
(function() {
    var OriginTitile = document.title, titleTime;
    document.addEventListener('visibilitychange', function() {
        if (document.hidden) {
            document.title = '死鬼去哪里了！';
            clearTimeout(titleTime);
        } else {
            document.title = '(つェ⊂)咦!又好了!';
            titleTime = setTimeout(function() {
                document.title = OriginTitile;
            },2000);
        }
    });
})();
</script>



</body>
</html>
